#ifndef VMTIMER_H_
#define VMTIMER_H_

#include "vmsys.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum
{
	
	VM_TIMER_MTK_TIMER_NO_FREE = -5,
	VM_TIMER_ERROR_OF_PROCESS,
	VM_TIMER_ERROR_OF_RES ,
	VM_TIMER_ERROR_OF_MEM ,
	VM_TIMER_ERROR ,
	VM_TIMER_OK
} vm_timer_error_t;

typedef void (*VM_TIMERPROC_T)(VMINT tid);

/**
 * Create a timer which would enter sleep state when Phone backlight is off(means it run slowly).
 * After a timer is created, system will keep calling back the timer handler 
 * until vm_delete_timer() is called to delete it. Before program exit,
 * all the timers should be deleted.
 *
 * @param millisec		interval of timer, unit in ms
 * @param timerproc		timer handler after the interval
 *
 * @return				>=0: Timer ID; <0: Failed
 */
VMINT vm_create_timer(VMUINT32 millisec, VM_TIMERPROC_T timerproc);

/**
 * Delete the timer of specified ID.
 *
 * @param timerid		Timer ID
 *
 * @return				0: Success; <0: Failed
 */
VMINT vm_delete_timer(VMINT timerid);

/**
 * Create a timer which works normally when Phone backlight is off.
 * After a timer is created, system will keep calling back the timer handler 
 * until vm_delete_timer() is called to delete it. Before program exit,
 * all the timers should be deleted.
 *
 * @param millisec		interval of timer, unit in ms
 * @param timerproc		timer handler after the interval
 *
 * @return				>=0: Timer ID; <0: Failed
 */
VMINT vm_create_timer_ex(VMUINT32 millisec, VM_TIMERPROC_T timerproc);


/**
 * Delete the timer of specified ID.
 *
 * @param timerid		Timer ID
 *
 * @return				0: Success; <0: Failed
 */
VMINT vm_delete_timer_ex(VMINT timerid);


#ifdef __cplusplus
}
#endif

#endif